
// 维护 loading 状态
import { ref } from 'vue'
const useFetch = function (handlerFetch) {
  if (typeof handlerFetch !== 'function') {
    throw Error('handlerFetch is not a function!')
  }
  const isLoading = ref(false)
  isLoading.value = true
  const fetch = async (params) => {
    try {
      await handlerFetch(params)
      isLoading.value = false
    } catch {

    }
  }
  return {
    fetch,
    isLoading
  }
}
export default useFetch
